package com.gf.forcesystem.mq.weatherparse;

import com.gf.forcesystem.model.dto.weather.AbstractWeather;
import com.gf.forcesystem.model.dto.weather.SimulationTime;
import org.springframework.stereotype.Service;

import java.nio.ByteBuffer;

/**
 * @author gaofei
 * @date 2022/6/24 21:34
 */
@Service("SimulationTimeParse")
public class SimulationTimeParse implements IWeatherParse{
    @Override
    public byte identifier() {
        return (byte)0xC0;
    }

    @Override
    public AbstractWeather parse(ByteBuffer byteBuffer) {
        SimulationTime simulationTime = new SimulationTime();
        simulationTime.setTime((short) (0xFF & byteBuffer.get()));
        simulationTime.setTimeCoefficient(byteBuffer.getShort());
        return simulationTime;
    }
}
